- Agenda: 

1) Increment/decrement operator

x++; // postfix ++
++x; // prefix ++

When used alone, they increment the value of x by 1

int x = 5;

x++;

y = ++x; 
prefix ++ higher priority than =
++x; y = x; // x = 7 and y = 7

z = y++;
assignment = has higher priority than postfix ++
z = y; y++; // z = 7 and y = 8

C ---> C++

Example#1: IncrementDemo.java


There are three different ways to increment a variable 1: 
1.a) x = x + 1;
1.b) x += 1;
// x *= b;
// x /= b;
// x %= b;
1.c) x++; or ++x;


2) Data conversion

2.a) Assignment:
float value =23.5; // Invalid

23.5 is a double (64)
value is a float (32)
= does not support narrowing conversion

int dollars = 25;
double money = dollars;

System.out.println("Money: " + money); // Money: 25.0
System.out.println(dollars); // 25

int (32 bits) ===> double (64) ---> widening conversion

2.b) promotion


7.0 / 2 ---> 7.0 / 2.0 ---> 3.5

"hi" + 5 ---> "hi" + "5" ---> "hi5"

2.c) casting

1	4	5

int sum = 10;
int count = 3;

double avg = (double) sum / count;

sum / (double) count;

(double) sum / count; // (double) 10 / 3

If division goes first, we end up 3.0
If casting goes first, we end up 3.3333...
Cast operator has the higher priority

(double) (sum / count) ---> yields 3.0

double money = 23.5;
int dollars = (int) money;


3) Interactive programs ----> Object oriented programming
Classes to create objects 
Scanner

Example#2: Echo.java



